package com.xrh.xdemo.api.request.queryRequest;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;

import cn.hutool.core.util.StrUtil;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

@Data
@JsonIgnoreProperties(ignoreUnknown = true)
public class SysDictQueryRequest {

	/**配置类型 */
	@ApiModelProperty("配置类型")
	private String type;
	
	/**配置类型名称 */
	@ApiModelProperty("配置类型名称")
	private String typeCnName;

	/**业务key */
	@ApiModelProperty("业务key")
	private String businessKey;
	
    @ApiModelProperty(value = "当前页码" )
    private Integer pageNum = 1;

    @ApiModelProperty(value = "每页数量" )
    private Integer pageSize = 10;
    
  //获取查询条件,注释部分要自己填写
  	public <T> QueryWrapper<T> createQuery() {
  			
  		QueryWrapper<T> queryWrapper = new QueryWrapper<T>();
  		

  		if(StrUtil.isNotBlank(type))
  			queryWrapper.eq("type", type);

  		if(StrUtil.isNotBlank(typeCnName))
  			queryWrapper.eq("type_cn_name", typeCnName);
  		
  		if(StrUtil.isNotBlank(businessKey))
  			queryWrapper.eq("businessKey", businessKey);

  		return queryWrapper;
  	}
	
	//获取分页
   public <T> Page<T> createPage(){
	   return new Page<>(pageNum , pageSize);
   }
	   
}
